Type-Based Methods for Termination and Productivity in Coq
نویسندگان
چکیده
Coq is a total dependently-typed programming language: recursive functions must be terminating and co-recursive functions must be productive. The requirement of totality is essential to ensure logical consistency, since a non-terminating function can be easily used to encode a proof of falsity. Systems based on dependent type theories, such as Coq and Agda, typically use syntactic methods, called guard predicates in Coq, to ensure termination (and productivity). A guard predicate is a form of static analysis, performed on the body of recursive functions, that checks that recursive functions are placed on structurally smaller arguments. Guard predicates were initially implemented in Coq over 15 years ago by Eduardo Giménez. Throughout the years, the guard predicate implementation has been relaxed and extended, in order to accept more recursion patterns as terminating (the most recent addition involves commutative cuts [6]). As a result, the implementation is large and difficult to maintain, making the termination checker one of the weakest point in the Coq kernel. This is highly undesirable, since any bug at this level jeopardizes logical consistency. Furthermore, the metatheoretical properties of the implemented extensions have not been studied (in particular, logical consistency). From the user point of view, the limitations of syntactic-based termination appear often in practice. Let us illustrate with a typical example. Consider the following definitions of subtraction and division on natural numbers, where divx y computes d x y+1e by repeated subtraction:
منابع مشابه
Well-Founded Sized Types in the Calculus of (Co)Inductive Constructions
Type-based termination is a mechanism for ensuring termination and productivity of (co)recursive definitions [4]. Its main feature is the use of sized types (i.e. types annotated with size information) to track the size of arguments in (co)recursive calls. Termination of recursive function (and productivity of corecursive functions) is ensured by restricting recursive calls to smaller arguments...
متن کاملA Unifying Approach to Recursive and Co-recursive Definitions
In type theory based logical frameworks, recursive and corecursive definitions are subject to syntactic restrictions that ensure their termination and productivity. These restrictions however greately decrease the expressive power of the language. In this work we propose a general approach for systematically defining fixed points for a broad class of well given recursive definition. This approa...
متن کاملOn type-based termination and dependent pattern matching in the calculus of inductive constructions. (Terminaison basée sur les types et filtrage dépendant pour le calcul des constructions inductives)
Proof assistants based on dependent type theory are progressively used as a tool to develop certified programs. A successful example is the Coq proof assistant, an implementation of a dependent type theory called the Calculus of Inductive Constructions (CIC). Coq is a functional programming language with an expressive type system that allows to specify and prove properties of programs in a high...
متن کاملRecursion on Nested Datatypes in Dependent Type Theory
Nested datatypes are families of datatypes that are indexed over all types and where the datatype constructors relate different members of the family. This may be used to represent variable binding or to maintain certain invariants through typing. In dependent type theory, a major concern is the termination of all expressible programs, so that types that depend on object terms can still be type...
متن کاملStop When You Are Almost-Full - Adventures in Constructive Termination
Disjunctive well-foundedness, size-change termination, and well-quasi-orders are examples of techniques that have been successfully applied to program termination. Although these works originate in different communities, they rely on closely related principles and both employ similar arguments from Ramsey theory. At the same time there is a notable absence of these techniques in programming sys...
متن کامل